import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:snappable/snappable.dart';

main() => runApp(TApp());
final ctrlKey = GlobalKey<SnappableState>();

class TApp extends StatelessWidget {
  @override
  build(context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    setState(() {
      SystemChrome.setSystemUIOverlayStyle(
          SystemUiOverlayStyle(statusBarColor: Colors.transparent));
      SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);
    });
    super.initState();
  }

  @override
  build(context) => Scaffold(
      backgroundColor: Colors.white,
      appBar: PreferredSize(child: Container(), preferredSize: Size.zero),
      body: Stack(
        children: <Widget>[
          GestureDetector(
            onTap: () {
              ctrlKey.currentState.isGone
                  ? ctrlKey.currentState.reset()
                  : ctrlKey.currentState.snap();
            },
            child: Snappable(
              key: ctrlKey,
              child: Container(
                margin: EdgeInsets.only(right: 32.0),
                height: MediaQuery.of(context).size.height,
                child: Image.asset(
                  'asset/image/me.png',
                  fit: BoxFit.values[4],
                ),
              ),
            ),
          ),
        ],
      ));
}
